<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title><spring:message code="menu.title.first.third"/> </title>
<meta name="Keywords" content="南通大学，通大">
<meta name="Description" content="南通大学，通大，复习资料共享">


</head>
<body>
	<div id="particles">
		<div class="intro">
			<div class="container">
				<div class="row" style="padding: 30px">
					<div class="col-md-3 col-centered tac">
						<h3 style="color:black"><spring:message code="upload.materials"/> </h3>
					</div>
				</div>
				<div class="row">
					<div class="col-md-5 col-sm-8 col-centered">
						<form id="form" method="post" id="register-form" enctype="multipart/form-data"
							  action="${pageContext.request.contextPath}/materials/materials${style}"
							  class="nice-validator n-default" novalidate>
							<div class="form-group validator-tips">
								<input type="text" class="form-control" id="xq" name="xq"
									   placeholder="<spring:message code="xq"/> " required="required" >
								<div class="error xq-null" hidden>
									<spring:message code="required"/>
								</div>
							</div>
							<div class="form-group validator-tips">
								<input type="subject" class="form-control" id="subject" name="subject"
									   placeholder="<spring:message code="subject"/> " required="required">
								<div class="error subject-null" hidden>
									<spring:message code="required"/>
								</div>
							</div>
							<div class="form-group validator-tips">
								<input type="text" class="form-control" id="teacher" name="teacher"
									   placeholder="<spring:message code="teacher"/> "  required="required">
								<div class="error teacher-null" hidden>
									<spring:message code="required"/>
								</div>
							</div>
							<div class="form-group validator-tips" id="fileInput">
								<input id="id" type="hidden" value="1">
								<label for="materials1" type="text" class="form-control file-box">
									<spring:message code="materials.choosefile"/>
								</label>
								<input type="file" id="materials1" name="materials" style="display: none;" onchange="choosedfile(this)">
								<div class="error file-null" hidden>
									<spring:message code="required.file"/>
								</div>
							</div>
							<div class="form-group validator-tips">
							<textarea rows="3" cols="5" class="form-control textarea" id="describe"
									  name="describe" placeholder="<spring:message code="describe"/> "></textarea>
								<div class="error describe-null" hidden>
									<spring:message code="required"/>
								</div>
							</div>
							<div class="checkbox validator-tips">
								<label> <input type="checkbox" name="offline" value="1"> <spring:message code="materials.offline"/> </label>
								<div class="error userAgreement-null" hidden>
									<spring:message code="required.check"/>
								</div>
							</div>
							<div class="checkbox validator-tips">
								<label> <input type="checkbox" id="checkbox" > <spring:message code="agreement"/> </label>
								<a id="userAgreement" style="text-decoration: none"><spring:message code="userAgreement"/> </a>
								<div class="error userAgreement-null" hidden>
									<spring:message code="required.check"/>
								</div>
							</div>
							<div class="form-group">
								<input type="button" id="submit_button"
									   class="form-control btn btn-primary btn-current"
									   value="<spring:message code="submmit"/> ">
							</div>
							<div class="form-group">
								<input type="button" id="reset_button"
									   class="form-control btn btn-default btn-current"
									   value="<spring:message code="cancel"/> ">
							</div>
						</form>
					</div>
				</div>
			</div>

			<div class="modal fade" id="myModal" tabindex="-1"
				style="text-align: left" role="dialog">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">×</span>
							</button>
							<h4 class="modal-title"><spring:message code="userAgreement"/> </h4>
						</div>
						<div class="modal-body" id="agreementContent">
							<h3>
								<spring:message code="materials.userAgreement"/>
							</h3>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		function reloadImg(t) {
			t.src = "${pageContext.request.contextPath}/user/getYzm.ztc?a="
					+ Math.random();
		}

        $('#reset_button').click(function(){
            $('#xq').val('');
            $('#subject').val('');
            $('#teacher').val('');
            $('#describe').val('');
            $('#checkbox').attr('checked',false);
            $('#id').val(1);
            var fileInput=$('#fileInput').empty();
            var first='<input id="id" type="hidden" value="1"> <label for="materials1" type="text" class="form-control file-box" ><spring:message code="materials.choosefile"/> </label> <input type="file" id="materials1" name="materials" style="display: none;" onchange="choosedfile(this)"> <div class="validator-tips file-null"style="color: red;" hidden>请至少选择一个文件！</div>';
            $('#fileInput').append(first);
        });

		$('#submit_button').click(function(){
			var xq = $('#xq').val().trim();
			var subject = $('#subject').val().trim();
			var teacher = $('#teacher').val().trim();
			var describe = $('#describe').val().trim();
            var materials1=$('#materials1').val();
            var submited=true;
            if(xq==''){
                submited=false;
                $('.xq-null').show();
            }else{
                $('.xq-null').hide();
            }
            if(subject==''){
                submited=false;
                $('.subject-null').show();
            }else{
                $('.subject-null').hide();
            }
            if(teacher==''){
                submited=false;
                $('.teacher-null').show();
            }else{
                $('.teacher-null').hide();
            }
            if(describe==''){
                submited=false;
                $('.describe-null').show();
            }else{
                $('.describe-null').hide();
            }
            if(!$('#checkbox').is(':checked')){
                submited=false;
                $('.userAgreement-null').show();
            }else{
                $('.userAgreement-null').hide();
            }
            if(materials1==''){
                submited=false;
                $('.file-null').show();
            }else {
                $('.file-null').hide();
            }
            if(submited)
                $('#form').submit();
		});

        function choosedfile(t){
            var filePath = $(t).val();
            var labelfor='[for="'+$(t).attr("id")+'"]';
            $(labelfor).text(filePath);
            var id=parseInt($('#id').val())+1;
            var add='<label for="materials'+id+'" type="text" class="form-control file-box" >请选择文件</label> <input type="file" id="materials'+id+'" name="materials" style="display: none;" onchange="choosedfile(this)">';
            $('#fileInput').append(add);
            $('#id').val(id);
        }

		$(document).ready(function() {
			$('#particles').particleground({
				dotColor : 'rgba(52, 152, 219, 0.36)',
				lineColor : 'rgba(52, 152, 219, 0.86)',
				density : 130000,
				proximity : 500,
				lineWidth : 0.2
			});

			$('#userAgreement').click(function() {
				$('#myModal').modal();
			});
		});
	</script>
</body>
</html>
